#include<bits/stdc++.h>
using namespace std;
int d[100010],u[100010],a[100010],n,m,l,v,p[100010],k[100010],g,ans = 1e9;
int check(){
    int sum = 0;double s;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= m;j++){
            if(k[i] || d[i] < p[j]) continue;
            int lc = p[j] - d[i];
            s = sqrt(u[i] * u[i] + 2 * a[i] * lc);
            if(s > v){
                sum++;
                break;
            }
        }
    }
    return sum;
}
void dfs(int t,int h){
    if(t > m){
        if(check() == g) ans = min(ans,h);
        return ;
    }
    k[t] = 0;
    dfs(t + 1,h);
    k[t] = 1;
    dfs(t + 1,h - 1);
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin >> t;
    while(t--){
        cin >> n >> m >> l >> v;
        for(int i = 1;i <= n;i++) cin >> d[i] >> u[i] >> a[i];
        for(int i = 1;i <= m;i++) cin >> p[i];
        g = check();
        dfs(1,n);
        cout << g << ' ' << ans << endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
